package com.fullertontech.framework.jdbc;

import java.util.Properties;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import com.fullertontech.framework.global.GlobalUtils;
import tk.mybatis.spring.mapper.MapperScannerConfigurer;
@Configuration
public class MapperScanConfig {
	
	@Bean
	@Conditional(MybatisPluginCondition.class)
	public MapperScannerConfigurer productMapperScannerConfigurer() {
		MapperScannerConfigurer mapperScannerConfigurer=new MapperScannerConfigurer();
		String basePackage=GlobalUtils.getMainClassPackageName().concat(".mapper").concat(",").concat(GlobalUtils.getMainClassPackageName()).concat(".dao")
				.concat(",").concat(GlobalUtils.getMainClassPackageName()).concat(".**.dao").concat(",").concat(GlobalUtils.getMainClassPackageName()).concat(".**.mapper");
		mapperScannerConfigurer.setBasePackage(basePackage);
		Properties properties=new Properties();
		properties.setProperty("mappers", "tk.mybatis.mapper.common.Mapper");
		properties.setProperty("IDENTITY", "MYSQL");
		properties.setProperty("notEmpty", "true");
		mapperScannerConfigurer.setProperties(properties);
		return mapperScannerConfigurer;
	}
	
	@Bean
	@Conditional(MybatisPlusPluginCondition.class)
	public org.mybatis.spring.mapper.MapperScannerConfigurer productMybatisPlusMapperScannerConfigurer() {
		org.mybatis.spring.mapper.MapperScannerConfigurer mapperScannerConfigurer=new org.mybatis.spring.mapper.MapperScannerConfigurer();
		String basePackage=GlobalUtils.getMainClassPackageName().concat(".mapper").concat(",").concat(GlobalUtils.getMainClassPackageName()).concat(".dao")
				.concat(",").concat(GlobalUtils.getMainClassPackageName()).concat(".**.dao").concat(",").concat(GlobalUtils.getMainClassPackageName()).concat(".**.mapper");
		mapperScannerConfigurer.setBasePackage(basePackage);
		return mapperScannerConfigurer;
	}
}
